import React from "react";
import FunctionsDialog from "./FuntionsDialog";

const Functions = (props) => {
    
    const handleClick = () => {
        FunctionsDialog.showModal().onClose(fun => {       
            // 调用API，往编辑器中插入一个数字
            props.editor.insertText(
                "{" + JSON.stringify(fun) + "}\n\n" 
            );
        });
    }

    return (
        <span
        className="button button-type-counter"
        title="取数函数"
        onClick={handleClick}
        >
        <i className="fa fa-calculator" />
        </span>
    );
}

Functions.align = 'left';
Functions.pluginName = 'functions';

export default Functions;